{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "64b201d8-746c-468c-974f-5640ef753c4a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from mindspore import context\n",
    "from mindspore.nn import Adam\n",
    "from mindsponge import Sponge\n",
    "from mindsponge import Molecule\n",
    "from mindsponge import ForceField\n",
    "from mindsponge import UpdaterMD\n",
    "from mindsponge import WithEnergyCell\n",
    "from mindsponge.potential import SphericalRestrict\n",
    "from mindsponge.function import VelocityGenerator\n",
    "from mindsponge.callback import WriteH5MD, RunInfo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6a411242-7bee-47e6-ba68-18cc655e2fc1",
   "metadata": {},
   "outputs": [],
   "source": [
    "context.set_context(mode=context.GRAPH_MODE, device_target=\"GPU\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d671c8a9-57dd-4c96-9f7f-e5a15c1aa5e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "system = Molecule(template='water.spce.yaml')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4c3da7f1-e846-4239-931e-35f185f3e698",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Molecule<>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "system.reduplicate([0.3, 0, 0])\n",
    "system.reduplicate([0, 0.3, 0])\n",
    "new_sys = system.copy([0, 0, -0.3])\n",
    "system.reduplicate([0, 0, 0.3])\n",
    "system.append(new_sys)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7c737ec6-b2ec-47d1-8c49-02ee72398e28",
   "metadata": {},
   "outputs": [],
   "source": [
    "potential = ForceField(system, parameters='SPCE')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9268c9f1-1470-4373-ba13-77ce107473ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "opt = Adam(system.trainable_params(), 1e-3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7fe11565-6074-4720-a75b-50384c3f72c8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[MindSPONGE] Using fully connected neighbour list (not updated).\n"
     ]
    }
   ],
   "source": [
    "mini = Sponge(system, potential, opt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "868a29e8-6f04-4881-9e4a-0bfa5ae53dfa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[MindSPONGE] Started simulation at 2023-06-30 16:27:08\n",
      "[MindSPONGE] Step: 0, E_pot: 242.99136\n",
      "[MindSPONGE] Step: 10, E_pot: 162.66307\n",
      "[MindSPONGE] Step: 20, E_pot: 91.999916\n",
      "[MindSPONGE] Step: 30, E_pot: 21.866974\n",
      "[MindSPONGE] Step: 40, E_pot: -43.896427\n",
      "[MindSPONGE] Step: 50, E_pot: -100.5366\n",
      "[MindSPONGE] Step: 60, E_pot: -159.18906\n",
      "[MindSPONGE] Step: 70, E_pot: -217.35576\n",
      "[MindSPONGE] Step: 80, E_pot: -263.58884\n",
      "[MindSPONGE] Step: 90, E_pot: -299.75137\n",
      "[MindSPONGE] Step: 100, E_pot: -330.5068\n",
      "[MindSPONGE] Step: 110, E_pot: -359.63373\n",
      "[MindSPONGE] Step: 120, E_pot: -389.3228\n",
      "[MindSPONGE] Step: 130, E_pot: -417.74637\n",
      "[MindSPONGE] Step: 140, E_pot: -441.52087\n",
      "[MindSPONGE] Step: 150, E_pot: -459.2307\n",
      "[MindSPONGE] Step: 160, E_pot: -471.3694\n",
      "[MindSPONGE] Step: 170, E_pot: -479.86255\n",
      "[MindSPONGE] Step: 180, E_pot: -486.56183\n",
      "[MindSPONGE] Step: 190, E_pot: -492.54034\n",
      "[MindSPONGE] Step: 200, E_pot: -498.02493\n",
      "[MindSPONGE] Step: 210, E_pot: -502.83423\n",
      "[MindSPONGE] Step: 220, E_pot: -506.86633\n",
      "[MindSPONGE] Step: 230, E_pot: -510.0587\n",
      "[MindSPONGE] Step: 240, E_pot: -512.37494\n",
      "[MindSPONGE] Step: 250, E_pot: -513.9593\n",
      "[MindSPONGE] Step: 260, E_pot: -515.0685\n",
      "[MindSPONGE] Step: 270, E_pot: -515.99146\n",
      "[MindSPONGE] Step: 280, E_pot: -516.855\n",
      "[MindSPONGE] Step: 290, E_pot: -517.65857\n",
      "[MindSPONGE] Step: 300, E_pot: -518.3301\n",
      "[MindSPONGE] Step: 310, E_pot: -518.8124\n",
      "[MindSPONGE] Step: 320, E_pot: -519.1519\n",
      "[MindSPONGE] Step: 330, E_pot: -519.4332\n",
      "[MindSPONGE] Step: 340, E_pot: -519.6985\n",
      "[MindSPONGE] Step: 350, E_pot: -519.9674\n",
      "[MindSPONGE] Step: 360, E_pot: -520.2644\n",
      "[MindSPONGE] Step: 370, E_pot: -520.6229\n",
      "[MindSPONGE] Step: 380, E_pot: -521.10205\n",
      "[MindSPONGE] Step: 390, E_pot: -521.80176\n",
      "[MindSPONGE] Step: 400, E_pot: -522.86395\n",
      "[MindSPONGE] Step: 410, E_pot: -524.4132\n",
      "[MindSPONGE] Step: 420, E_pot: -526.34033\n",
      "[MindSPONGE] Step: 430, E_pot: -528.3999\n",
      "[MindSPONGE] Step: 440, E_pot: -530.3782\n",
      "[MindSPONGE] Step: 450, E_pot: -532.1981\n",
      "[MindSPONGE] Step: 460, E_pot: -533.8815\n",
      "[MindSPONGE] Step: 470, E_pot: -535.50146\n",
      "[MindSPONGE] Step: 480, E_pot: -537.18384\n",
      "[MindSPONGE] Step: 490, E_pot: -539.0304\n",
      "[MindSPONGE] Step: 500, E_pot: -540.91547\n",
      "[MindSPONGE] Step: 510, E_pot: -542.25116\n",
      "[MindSPONGE] Step: 520, E_pot: -542.8058\n",
      "[MindSPONGE] Step: 530, E_pot: -543.1375\n",
      "[MindSPONGE] Step: 540, E_pot: -543.4234\n",
      "[MindSPONGE] Step: 550, E_pot: -543.6314\n",
      "[MindSPONGE] Step: 560, E_pot: -543.797\n",
      "[MindSPONGE] Step: 570, E_pot: -543.9352\n",
      "[MindSPONGE] Step: 580, E_pot: -544.0567\n",
      "[MindSPONGE] Step: 590, E_pot: -544.1638\n",
      "[MindSPONGE] Step: 600, E_pot: -544.2654\n",
      "[MindSPONGE] Step: 610, E_pot: -544.3639\n",
      "[MindSPONGE] Step: 620, E_pot: -544.464\n",
      "[MindSPONGE] Step: 630, E_pot: -544.5674\n",
      "[MindSPONGE] Step: 640, E_pot: -544.6753\n",
      "[MindSPONGE] Step: 650, E_pot: -544.7878\n",
      "[MindSPONGE] Step: 660, E_pot: -544.9033\n",
      "[MindSPONGE] Step: 670, E_pot: -545.01587\n",
      "[MindSPONGE] Step: 680, E_pot: -545.1382\n",
      "[MindSPONGE] Step: 690, E_pot: -545.25085\n",
      "[MindSPONGE] Step: 700, E_pot: -545.35986\n",
      "[MindSPONGE] Step: 710, E_pot: -545.4604\n",
      "[MindSPONGE] Step: 720, E_pot: -545.55347\n",
      "[MindSPONGE] Step: 730, E_pot: -545.6363\n",
      "[MindSPONGE] Step: 740, E_pot: -545.7107\n",
      "[MindSPONGE] Step: 750, E_pot: -545.7748\n",
      "[MindSPONGE] Step: 760, E_pot: -545.8191\n",
      "[MindSPONGE] Step: 770, E_pot: -545.87054\n",
      "[MindSPONGE] Step: 780, E_pot: -545.9171\n",
      "[MindSPONGE] Step: 790, E_pot: -545.94965\n",
      "[MindSPONGE] Step: 800, E_pot: -545.978\n",
      "[MindSPONGE] Step: 810, E_pot: -546.0011\n",
      "[MindSPONGE] Step: 820, E_pot: -546.01965\n",
      "[MindSPONGE] Step: 830, E_pot: -546.035\n",
      "[MindSPONGE] Step: 840, E_pot: -546.04675\n",
      "[MindSPONGE] Step: 850, E_pot: -546.05676\n",
      "[MindSPONGE] Step: 860, E_pot: -546.0646\n",
      "[MindSPONGE] Step: 870, E_pot: -546.0646\n",
      "[MindSPONGE] Step: 880, E_pot: -546.074\n",
      "[MindSPONGE] Step: 890, E_pot: -546.077\n",
      "[MindSPONGE] Step: 900, E_pot: -546.08344\n",
      "[MindSPONGE] Step: 910, E_pot: -546.0858\n",
      "[MindSPONGE] Step: 920, E_pot: -546.0885\n",
      "[MindSPONGE] Step: 930, E_pot: -546.0897\n",
      "[MindSPONGE] Step: 940, E_pot: -546.09125\n",
      "[MindSPONGE] Step: 950, E_pot: -546.0919\n",
      "[MindSPONGE] Step: 960, E_pot: -546.0924\n",
      "[MindSPONGE] Step: 970, E_pot: -546.0778\n",
      "[MindSPONGE] Step: 980, E_pot: -546.0853\n",
      "[MindSPONGE] Step: 990, E_pot: -546.0909\n",
      "[MindSPONGE] Finished simulation at 2023-06-30 16:27:16\n",
      "[MindSPONGE] Simulation time: 7.80 seconds.\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<mindsponge.core.sponge.Sponge at 0x7f7a64daa1f0>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "run_info = RunInfo(10)\n",
    "mini.run(1000, callbacks=[run_info])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e57c0c80-7440-44e8-96df-7e832b345d4f",
   "metadata": {},
   "outputs": [],
   "source": [
    "temp = 300\n",
    "vgen = VelocityGenerator(temp)\n",
    "velocity = vgen(system.shape, system.atom_mass)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3914136b-0e40-4fa4-a49f-ced2a7309034",
   "metadata": {},
   "outputs": [],
   "source": [
    "opt = UpdaterMD(system=system,\n",
    "                time_step=1e-3,\n",
    "                velocity=velocity,\n",
    "                integrator='velocity_verlet',\n",
    "                temperature=300,\n",
    "                thermostat='langevin',)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "1817479d-5d74-407e-aac4-546a80aeb0c9",
   "metadata": {},
   "source": [
    "## 外加限制\n",
    "\n",
    "在MindSPONGE的WithEnergyCell中可以自定义一些外加的势能项，这是一个非常灵活的操作，支持同时定义多个Bias叠加使用，并且在MindSpore框架的支持下都是可微的。比如本案例中施加的Bias是中心球形势SphericalRestrict，用于把原子的运动限制在一个球形范围内。另外MindSponge也支持原位谐振子势OscillatorBias，可以将原子限制在原始位置附近，这个功能在蛋白质预测中能够起到较大的作用。基于MindSPONGE的基础类PotentialCell，用户还可以自定义更多种类的Bias。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9675cb26-4bbb-4d51-b214-bde2440d9419",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[MindSPONGE] Using fully connected neighbour list (not updated).\n"
     ]
    }
   ],
   "source": [
    "sim = WithEnergyCell(system, potential, bias=SphericalRestrict(radius=1.5, center=[0, 0, 0]))\n",
    "md = Sponge(sim, optimizer=opt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2bf21ab2-cad5-4ac7-95db-53741748a8aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "cb_h5md = WriteH5MD(system, 'tutorial_b04.h5md', save_freq=10, write_velocity=True, write_force=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0feb9749-4989-4dcc-9ab4-720c3a1cd91b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[MindSPONGE] Started simulation at 2023-06-30 16:27:22\n",
      "[MindSPONGE] Step: 0, E_pot: -546.09375, E_kin: 163.0075, E_tot: -383.08624, Temperature: 373.43423\n",
      "[MindSPONGE] Step: 10, E_pot: -485.7534, E_kin: 112.67149, E_tot: -373.0819, Temperature: 258.11935\n",
      "[MindSPONGE] Step: 20, E_pot: -464.64957, E_kin: 92.389885, E_tot: -372.25967, Temperature: 211.65617\n",
      "[MindSPONGE] Step: 30, E_pot: -454.0137, E_kin: 76.92503, E_tot: -377.08868, Temperature: 176.2277\n",
      "[MindSPONGE] Step: 40, E_pot: -469.77313, E_kin: 86.45755, E_tot: -383.31558, Temperature: 198.06578\n",
      "[MindSPONGE] Step: 50, E_pot: -465.74377, E_kin: 99.71851, E_tot: -366.02527, Temperature: 228.44534\n",
      "[MindSPONGE] Step: 60, E_pot: -454.39484, E_kin: 94.81408, E_tot: -359.58075, Temperature: 217.20978\n",
      "[MindSPONGE] Step: 70, E_pot: -443.4588, E_kin: 95.24145, E_tot: -348.21735, Temperature: 218.18883\n",
      "[MindSPONGE] Step: 80, E_pot: -443.7237, E_kin: 103.214676, E_tot: -340.50903, Temperature: 236.45473\n",
      "[MindSPONGE] Step: 90, E_pot: -443.06638, E_kin: 107.387856, E_tot: -335.67853, Temperature: 246.01505\n",
      "[MindSPONGE] Step: 100, E_pot: -427.24078, E_kin: 103.413956, E_tot: -323.82684, Temperature: 236.91124\n",
      "[MindSPONGE] Step: 110, E_pot: -432.11386, E_kin: 103.62134, E_tot: -328.49252, Temperature: 237.38634\n",
      "[MindSPONGE] Step: 120, E_pot: -432.25388, E_kin: 104.659386, E_tot: -327.59448, Temperature: 239.7644\n",
      "[MindSPONGE] Step: 130, E_pot: -424.21606, E_kin: 101.81855, E_tot: -322.39752, Temperature: 233.25632\n",
      "[MindSPONGE] Step: 140, E_pot: -422.98285, E_kin: 99.92085, E_tot: -323.062, Temperature: 228.90889\n",
      "[MindSPONGE] Step: 150, E_pot: -416.09338, E_kin: 104.348206, E_tot: -311.74518, Temperature: 239.05151\n",
      "[MindSPONGE] Step: 160, E_pot: -410.86166, E_kin: 88.43248, E_tot: -322.4292, Temperature: 202.59015\n",
      "[MindSPONGE] Step: 170, E_pot: -423.72873, E_kin: 100.52539, E_tot: -323.20334, Temperature: 230.29382\n",
      "[MindSPONGE] Step: 180, E_pot: -435.36786, E_kin: 105.62606, E_tot: -329.7418, Temperature: 241.97896\n",
      "[MindSPONGE] Step: 190, E_pot: -430.51495, E_kin: 101.534004, E_tot: -328.98096, Temperature: 232.60446\n",
      "[MindSPONGE] Step: 200, E_pot: -428.00613, E_kin: 93.58307, E_tot: -334.42307, Temperature: 214.38963\n",
      "[MindSPONGE] Step: 210, E_pot: -436.49432, E_kin: 98.9706, E_tot: -337.52374, Temperature: 226.73195\n",
      "[MindSPONGE] Step: 220, E_pot: -441.14163, E_kin: 111.997475, E_tot: -329.14417, Temperature: 256.57526\n",
      "[MindSPONGE] Step: 230, E_pot: -437.50793, E_kin: 121.24014, E_tot: -316.2678, Temperature: 277.74927\n",
      "[MindSPONGE] Step: 240, E_pot: -414.51422, E_kin: 94.28459, E_tot: -320.2296, Temperature: 215.99677\n",
      "[MindSPONGE] Step: 250, E_pot: -433.85287, E_kin: 120.63597, E_tot: -313.21692, Temperature: 276.36517\n",
      "[MindSPONGE] Step: 260, E_pot: -410.16095, E_kin: 124.584854, E_tot: -285.5761, Temperature: 285.41168\n",
      "[MindSPONGE] Step: 270, E_pot: -407.36435, E_kin: 115.51236, E_tot: -291.852, Temperature: 264.6275\n",
      "[MindSPONGE] Step: 280, E_pot: -411.85162, E_kin: 131.70381, E_tot: -280.14783, Temperature: 301.72055\n",
      "[MindSPONGE] Step: 290, E_pot: -396.24646, E_kin: 129.07162, E_tot: -267.17484, Temperature: 295.69043\n",
      "[MindSPONGE] Step: 300, E_pot: -383.80295, E_kin: 137.16887, E_tot: -246.63408, Temperature: 314.24045\n",
      "[MindSPONGE] Step: 310, E_pot: -381.73053, E_kin: 122.04378, E_tot: -259.68677, Temperature: 279.59033\n",
      "[MindSPONGE] Step: 320, E_pot: -390.1742, E_kin: 136.75699, E_tot: -253.4172, Temperature: 313.29688\n",
      "[MindSPONGE] Step: 330, E_pot: -377.87793, E_kin: 135.72319, E_tot: -242.15474, Temperature: 310.92853\n",
      "[MindSPONGE] Step: 340, E_pot: -377.95728, E_kin: 134.6319, E_tot: -243.32538, Temperature: 308.4285\n",
      "[MindSPONGE] Step: 350, E_pot: -372.537, E_kin: 127.91213, E_tot: -244.62485, Temperature: 293.03418\n",
      "[MindSPONGE] Step: 360, E_pot: -377.34787, E_kin: 135.32214, E_tot: -242.02573, Temperature: 310.0098\n",
      "[MindSPONGE] Step: 370, E_pot: -348.7042, E_kin: 117.60347, E_tot: -231.10072, Temperature: 269.41803\n",
      "[MindSPONGE] Step: 380, E_pot: -352.38312, E_kin: 122.4604, E_tot: -229.92271, Temperature: 280.5448\n",
      "[MindSPONGE] Step: 390, E_pot: -359.2214, E_kin: 137.41862, E_tot: -221.80278, Temperature: 314.81262\n",
      "[MindSPONGE] Step: 400, E_pot: -353.74817, E_kin: 131.61168, E_tot: -222.13649, Temperature: 301.50946\n",
      "[MindSPONGE] Step: 410, E_pot: -375.34238, E_kin: 137.56992, E_tot: -237.77246, Temperature: 315.1592\n",
      "[MindSPONGE] Step: 420, E_pot: -379.37115, E_kin: 133.94191, E_tot: -245.42924, Temperature: 306.8478\n",
      "[MindSPONGE] Step: 430, E_pot: -386.69855, E_kin: 142.33452, E_tot: -244.36403, Temperature: 326.07443\n",
      "[MindSPONGE] Step: 440, E_pot: -400.1266, E_kin: 129.70831, E_tot: -270.41827, Temperature: 297.14905\n",
      "[MindSPONGE] Step: 450, E_pot: -388.06763, E_kin: 128.9796, E_tot: -259.088, Temperature: 295.4796\n",
      "[MindSPONGE] Step: 460, E_pot: -387.36188, E_kin: 114.673744, E_tot: -272.68814, Temperature: 262.70633\n",
      "[MindSPONGE] Step: 470, E_pot: -385.15662, E_kin: 123.748886, E_tot: -261.4077, Temperature: 283.49658\n",
      "[MindSPONGE] Step: 480, E_pot: -387.40045, E_kin: 141.26044, E_tot: -246.14001, Temperature: 323.61383\n",
      "[MindSPONGE] Step: 490, E_pot: -387.346, E_kin: 130.83556, E_tot: -256.51044, Temperature: 299.73145\n",
      "[MindSPONGE] Step: 500, E_pot: -396.86163, E_kin: 129.39778, E_tot: -267.46387, Temperature: 296.43762\n",
      "[MindSPONGE] Step: 510, E_pot: -402.14655, E_kin: 137.81361, E_tot: -264.33295, Temperature: 315.7175\n",
      "[MindSPONGE] Step: 520, E_pot: -406.3318, E_kin: 141.8815, E_tot: -264.4503, Temperature: 325.03662\n",
      "[MindSPONGE] Step: 530, E_pot: -419.47064, E_kin: 142.32977, E_tot: -277.14087, Temperature: 326.06357\n",
      "[MindSPONGE] Step: 540, E_pot: -426.22467, E_kin: 125.98993, E_tot: -300.23474, Temperature: 288.63058\n",
      "[MindSPONGE] Step: 550, E_pot: -403.8053, E_kin: 126.47627, E_tot: -277.32904, Temperature: 289.74475\n",
      "[MindSPONGE] Step: 560, E_pot: -405.88837, E_kin: 123.81412, E_tot: -282.07425, Temperature: 283.64603\n",
      "[MindSPONGE] Step: 570, E_pot: -394.31174, E_kin: 114.34919, E_tot: -279.96255, Temperature: 261.9628\n",
      "[MindSPONGE] Step: 580, E_pot: -409.30936, E_kin: 120.02678, E_tot: -289.2826, Temperature: 274.9696\n",
      "[MindSPONGE] Step: 590, E_pot: -407.0149, E_kin: 126.45975, E_tot: -280.55515, Temperature: 289.7069\n",
      "[MindSPONGE] Step: 600, E_pot: -414.94647, E_kin: 139.84271, E_tot: -275.10376, Temperature: 320.36597\n",
      "[MindSPONGE] Step: 610, E_pot: -423.32806, E_kin: 135.39902, E_tot: -287.92905, Temperature: 310.18588\n",
      "[MindSPONGE] Step: 620, E_pot: -414.3127, E_kin: 127.16201, E_tot: -287.1507, Temperature: 291.3157\n",
      "[MindSPONGE] Step: 630, E_pot: -416.89746, E_kin: 123.21542, E_tot: -293.68204, Temperature: 282.27448\n",
      "[MindSPONGE] Step: 640, E_pot: -440.64972, E_kin: 139.33775, E_tot: -301.31195, Temperature: 319.20917\n",
      "[MindSPONGE] Step: 650, E_pot: -433.0719, E_kin: 122.01276, E_tot: -311.05914, Temperature: 279.5193\n",
      "[MindSPONGE] Step: 660, E_pot: -431.85583, E_kin: 113.79736, E_tot: -318.05847, Temperature: 260.69864\n",
      "[MindSPONGE] Step: 670, E_pot: -447.40326, E_kin: 121.033226, E_tot: -326.37003, Temperature: 277.27527\n",
      "[MindSPONGE] Step: 680, E_pot: -427.02673, E_kin: 116.587875, E_tot: -310.43884, Temperature: 267.0914\n",
      "[MindSPONGE] Step: 690, E_pot: -409.05505, E_kin: 93.37775, E_tot: -315.6773, Temperature: 213.91927\n",
      "[MindSPONGE] Step: 700, E_pot: -430.79352, E_kin: 111.90884, E_tot: -318.88467, Temperature: 256.37216\n",
      "[MindSPONGE] Step: 710, E_pot: -420.4088, E_kin: 120.657135, E_tot: -299.75168, Temperature: 276.41367\n",
      "[MindSPONGE] Step: 720, E_pot: -436.7754, E_kin: 142.44058, E_tot: -294.3348, Temperature: 326.3174\n",
      "[MindSPONGE] Step: 730, E_pot: -431.88095, E_kin: 142.1395, E_tot: -289.74146, Temperature: 325.62766\n",
      "[MindSPONGE] Step: 740, E_pot: -427.85587, E_kin: 136.46991, E_tot: -291.38596, Temperature: 312.6392\n",
      "[MindSPONGE] Step: 750, E_pot: -414.09003, E_kin: 131.57617, E_tot: -282.51385, Temperature: 301.4281\n",
      "[MindSPONGE] Step: 760, E_pot: -416.91388, E_kin: 138.60233, E_tot: -278.31155, Temperature: 317.52435\n",
      "[MindSPONGE] Step: 770, E_pot: -423.4786, E_kin: 151.29433, E_tot: -272.18427, Temperature: 346.60046\n",
      "[MindSPONGE] Step: 780, E_pot: -431.9049, E_kin: 140.58614, E_tot: -291.3188, Temperature: 322.06906\n",
      "[MindSPONGE] Step: 790, E_pot: -416.66272, E_kin: 102.662994, E_tot: -313.99973, Temperature: 235.19086\n",
      "[MindSPONGE] Step: 800, E_pot: -423.34747, E_kin: 112.23346, E_tot: -311.114, Temperature: 257.11588\n",
      "[MindSPONGE] Step: 810, E_pot: -426.0113, E_kin: 116.397804, E_tot: -309.6135, Temperature: 266.65598\n",
      "[MindSPONGE] Step: 820, E_pot: -401.84534, E_kin: 106.784775, E_tot: -295.06055, Temperature: 244.63345\n",
      "[MindSPONGE] Step: 830, E_pot: -416.88983, E_kin: 124.08566, E_tot: -292.80417, Temperature: 284.2681\n",
      "[MindSPONGE] Step: 840, E_pot: -415.40833, E_kin: 115.72987, E_tot: -299.67847, Temperature: 265.12582\n",
      "[MindSPONGE] Step: 850, E_pot: -415.03714, E_kin: 109.864655, E_tot: -305.1725, Temperature: 251.68918\n",
      "[MindSPONGE] Step: 860, E_pot: -407.07837, E_kin: 110.9902, E_tot: -296.08817, Temperature: 254.26767\n",
      "[MindSPONGE] Step: 870, E_pot: -404.18463, E_kin: 101.069305, E_tot: -303.11533, Temperature: 231.53989\n",
      "[MindSPONGE] Step: 880, E_pot: -421.20908, E_kin: 136.48671, E_tot: -284.72235, Temperature: 312.6777\n",
      "[MindSPONGE] Step: 890, E_pot: -425.2431, E_kin: 148.17404, E_tot: -277.06906, Temperature: 339.4522\n",
      "[MindSPONGE] Step: 900, E_pot: -393.74878, E_kin: 125.36532, E_tot: -268.38345, Temperature: 287.19968\n",
      "[MindSPONGE] Step: 910, E_pot: -412.41925, E_kin: 138.18265, E_tot: -274.2366, Temperature: 316.56293\n",
      "[MindSPONGE] Step: 920, E_pot: -398.16382, E_kin: 149.0037, E_tot: -249.16013, Temperature: 341.35287\n",
      "[MindSPONGE] Step: 930, E_pot: -390.46756, E_kin: 149.52231, E_tot: -240.94525, Temperature: 342.54095\n",
      "[MindSPONGE] Step: 940, E_pot: -421.37094, E_kin: 185.44604, E_tot: -235.9249, Temperature: 424.83875\n",
      "[MindSPONGE] Step: 950, E_pot: -378.37134, E_kin: 141.19724, E_tot: -237.1741, Temperature: 323.46906\n",
      "[MindSPONGE] Step: 960, E_pot: -378.2002, E_kin: 171.69743, E_tot: -206.50276, Temperature: 393.342\n",
      "[MindSPONGE] Step: 970, E_pot: -378.52383, E_kin: 147.33813, E_tot: -231.1857, Temperature: 337.53723\n",
      "[MindSPONGE] Step: 980, E_pot: -383.79913, E_kin: 156.12836, E_tot: -227.67078, Temperature: 357.67477\n",
      "[MindSPONGE] Step: 990, E_pot: -399.73315, E_kin: 156.66551, E_tot: -243.06764, Temperature: 358.90536\n",
      "[MindSPONGE] Step: 1000, E_pot: -421.69543, E_kin: 164.05966, E_tot: -257.63577, Temperature: 375.8446\n",
      "[MindSPONGE] Step: 1010, E_pot: -404.26566, E_kin: 144.25232, E_tot: -260.01334, Temperature: 330.46793\n",
      "[MindSPONGE] Step: 1020, E_pot: -400.88144, E_kin: 150.37077, E_tot: -250.51067, Temperature: 344.4847\n",
      "[MindSPONGE] Step: 1030, E_pot: -407.63528, E_kin: 154.33679, E_tot: -253.2985, Temperature: 353.5705\n",
      "[MindSPONGE] Step: 1040, E_pot: -414.89807, E_kin: 155.29538, E_tot: -259.6027, Temperature: 355.7665\n",
      "[MindSPONGE] Step: 1050, E_pot: -392.74768, E_kin: 116.04532, E_tot: -276.70236, Temperature: 265.84845\n",
      "[MindSPONGE] Step: 1060, E_pot: -406.97913, E_kin: 130.51593, E_tot: -276.4632, Temperature: 298.9992\n",
      "[MindSPONGE] Step: 1070, E_pot: -409.66443, E_kin: 140.12973, E_tot: -269.5347, Temperature: 321.0235\n",
      "[MindSPONGE] Step: 1080, E_pot: -420.91144, E_kin: 140.95381, E_tot: -279.95764, Temperature: 322.91138\n",
      "[MindSPONGE] Step: 1090, E_pot: -412.88855, E_kin: 124.48781, E_tot: -288.40076, Temperature: 285.18936\n",
      "[MindSPONGE] Step: 1100, E_pot: -414.0603, E_kin: 124.12077, E_tot: -289.9395, Temperature: 284.34854\n",
      "[MindSPONGE] Step: 1110, E_pot: -418.13824, E_kin: 133.43094, E_tot: -284.7073, Temperature: 305.6772\n",
      "[MindSPONGE] Step: 1120, E_pot: -409.18317, E_kin: 112.00112, E_tot: -297.18204, Temperature: 256.5836\n",
      "[MindSPONGE] Step: 1130, E_pot: -405.85748, E_kin: 131.22641, E_tot: -274.63107, Temperature: 300.62683\n",
      "[MindSPONGE] Step: 1140, E_pot: -415.87732, E_kin: 149.26695, E_tot: -266.61035, Temperature: 341.95596\n",
      "[MindSPONGE] Step: 1150, E_pot: -413.37683, E_kin: 138.04079, E_tot: -275.33606, Temperature: 316.2379\n",
      "[MindSPONGE] Step: 1160, E_pot: -436.66724, E_kin: 153.94159, E_tot: -282.72565, Temperature: 352.6651\n",
      "[MindSPONGE] Step: 1170, E_pot: -421.29047, E_kin: 129.17622, E_tot: -292.11426, Temperature: 295.93008\n",
      "[MindSPONGE] Step: 1180, E_pot: -444.02747, E_kin: 141.08072, E_tot: -302.94675, Temperature: 323.20212\n",
      "[MindSPONGE] Step: 1190, E_pot: -420.85895, E_kin: 119.87351, E_tot: -300.98544, Temperature: 274.61847\n",
      "[MindSPONGE] Step: 1200, E_pot: -435.9518, E_kin: 126.98403, E_tot: -308.96777, Temperature: 290.90796\n",
      "[MindSPONGE] Step: 1210, E_pot: -420.82593, E_kin: 115.86623, E_tot: -304.95972, Temperature: 265.43817\n",
      "[MindSPONGE] Step: 1220, E_pot: -413.12982, E_kin: 125.69798, E_tot: -287.43182, Temperature: 287.96176\n",
      "[MindSPONGE] Step: 1230, E_pot: -398.7898, E_kin: 119.9126, E_tot: -278.8772, Temperature: 274.708\n",
      "[MindSPONGE] Step: 1240, E_pot: -387.17233, E_kin: 105.312904, E_tot: -281.85944, Temperature: 241.26154\n",
      "[MindSPONGE] Step: 1250, E_pot: -415.68033, E_kin: 138.34502, E_tot: -277.33533, Temperature: 316.9349\n",
      "[MindSPONGE] Step: 1260, E_pot: -396.06583, E_kin: 120.86275, E_tot: -275.20306, Temperature: 276.88474\n",
      "[MindSPONGE] Step: 1270, E_pot: -391.26993, E_kin: 95.43092, E_tot: -295.839, Temperature: 218.6229\n",
      "[MindSPONGE] Step: 1280, E_pot: -407.30438, E_kin: 111.418884, E_tot: -295.8855, Temperature: 255.24974\n",
      "[MindSPONGE] Step: 1290, E_pot: -421.52985, E_kin: 138.68561, E_tot: -282.84424, Temperature: 317.71515\n",
      "[MindSPONGE] Step: 1300, E_pot: -420.65445, E_kin: 137.40869, E_tot: -283.24576, Temperature: 314.78986\n",
      "[MindSPONGE] Step: 1310, E_pot: -422.26605, E_kin: 131.38885, E_tot: -290.8772, Temperature: 300.999\n",
      "[MindSPONGE] Step: 1320, E_pot: -409.3877, E_kin: 118.857315, E_tot: -290.5304, Temperature: 272.29047\n",
      "[MindSPONGE] Step: 1330, E_pot: -414.3528, E_kin: 123.25743, E_tot: -291.0954, Temperature: 282.37073\n",
      "[MindSPONGE] Step: 1340, E_pot: -400.06964, E_kin: 101.0806, E_tot: -298.98904, Temperature: 231.56575\n",
      "[MindSPONGE] Step: 1350, E_pot: -411.91827, E_kin: 118.211136, E_tot: -293.70715, Temperature: 270.81015\n",
      "[MindSPONGE] Step: 1360, E_pot: -402.37708, E_kin: 102.80782, E_tot: -299.56924, Temperature: 235.52264\n",
      "[MindSPONGE] Step: 1370, E_pot: -416.7662, E_kin: 112.00952, E_tot: -304.75668, Temperature: 256.60284\n",
      "[MindSPONGE] Step: 1380, E_pot: -410.79828, E_kin: 107.737816, E_tot: -303.06046, Temperature: 246.81677\n",
      "[MindSPONGE] Step: 1390, E_pot: -404.9757, E_kin: 118.544586, E_tot: -286.43112, Temperature: 271.57404\n",
      "[MindSPONGE] Step: 1400, E_pot: -409.19128, E_kin: 105.61263, E_tot: -303.57864, Temperature: 241.9482\n",
      "[MindSPONGE] Step: 1410, E_pot: -410.53537, E_kin: 113.61609, E_tot: -296.91928, Temperature: 260.28333\n",
      "[MindSPONGE] Step: 1420, E_pot: -417.22528, E_kin: 135.99411, E_tot: -281.23117, Temperature: 311.5492\n",
      "[MindSPONGE] Step: 1430, E_pot: -412.66217, E_kin: 114.4716, E_tot: -298.19055, Temperature: 262.24326\n",
      "[MindSPONGE] Step: 1440, E_pot: -400.06564, E_kin: 124.71091, E_tot: -275.35474, Temperature: 285.70047\n",
      "[MindSPONGE] Step: 1450, E_pot: -385.4851, E_kin: 122.88019, E_tot: -262.60492, Temperature: 281.50647\n",
      "[MindSPONGE] Step: 1460, E_pot: -385.94952, E_kin: 138.07468, E_tot: -247.87485, Temperature: 316.31558\n",
      "[MindSPONGE] Step: 1470, E_pot: -400.4942, E_kin: 149.83003, E_tot: -250.66417, Temperature: 343.24594\n",
      "[MindSPONGE] Step: 1480, E_pot: -432.87506, E_kin: 153.26971, E_tot: -279.60535, Temperature: 351.12592\n",
      "[MindSPONGE] Step: 1490, E_pot: -434.2977, E_kin: 160.7267, E_tot: -273.57098, Temperature: 368.20914\n",
      "[MindSPONGE] Step: 1500, E_pot: -418.17065, E_kin: 141.06195, E_tot: -277.1087, Temperature: 323.15912\n",
      "[MindSPONGE] Step: 1510, E_pot: -415.6585, E_kin: 142.85367, E_tot: -272.80484, Temperature: 327.26376\n",
      "[MindSPONGE] Step: 1520, E_pot: -406.56152, E_kin: 114.91866, E_tot: -291.64285, Temperature: 263.2674\n",
      "[MindSPONGE] Step: 1530, E_pot: -406.98715, E_kin: 118.85942, E_tot: -288.12775, Temperature: 272.2953\n",
      "[MindSPONGE] Step: 1540, E_pot: -389.2693, E_kin: 109.578445, E_tot: -279.69086, Temperature: 251.0335\n",
      "[MindSPONGE] Step: 1550, E_pot: -386.3805, E_kin: 113.64689, E_tot: -272.7336, Temperature: 260.35388\n",
      "[MindSPONGE] Step: 1560, E_pot: -380.5558, E_kin: 108.966194, E_tot: -271.5896, Temperature: 249.63087\n",
      "[MindSPONGE] Step: 1570, E_pot: -383.05283, E_kin: 139.96826, E_tot: -243.08456, Temperature: 320.65356\n",
      "[MindSPONGE] Step: 1580, E_pot: -374.85074, E_kin: 109.07674, E_tot: -265.774, Temperature: 249.88412\n",
      "[MindSPONGE] Step: 1590, E_pot: -373.3407, E_kin: 127.066185, E_tot: -246.2745, Temperature: 291.0962\n",
      "[MindSPONGE] Step: 1600, E_pot: -368.1777, E_kin: 116.28458, E_tot: -251.89313, Temperature: 266.39658\n",
      "[MindSPONGE] Step: 1610, E_pot: -389.38004, E_kin: 140.37668, E_tot: -249.00336, Temperature: 321.58923\n",
      "[MindSPONGE] Step: 1620, E_pot: -397.5418, E_kin: 157.1749, E_tot: -240.36691, Temperature: 360.0723\n",
      "[MindSPONGE] Step: 1630, E_pot: -386.4344, E_kin: 131.23907, E_tot: -255.19531, Temperature: 300.65585\n",
      "[MindSPONGE] Step: 1640, E_pot: -355.03168, E_kin: 92.97925, E_tot: -262.05243, Temperature: 213.00635\n",
      "[MindSPONGE] Step: 1650, E_pot: -382.00034, E_kin: 109.4373, E_tot: -272.56305, Temperature: 250.71014\n",
      "[MindSPONGE] Step: 1660, E_pot: -383.76212, E_kin: 127.9799, E_tot: -255.78223, Temperature: 293.18942\n",
      "[MindSPONGE] Step: 1670, E_pot: -372.68408, E_kin: 115.60045, E_tot: -257.08362, Temperature: 264.8293\n",
      "[MindSPONGE] Step: 1680, E_pot: -378.99283, E_kin: 124.39671, E_tot: -254.59612, Temperature: 284.9807\n",
      "[MindSPONGE] Step: 1690, E_pot: -368.09113, E_kin: 112.27221, E_tot: -255.81891, Temperature: 257.20465\n",
      "[MindSPONGE] Step: 1700, E_pot: -376.82565, E_kin: 112.53683, E_tot: -264.28882, Temperature: 257.81082\n",
      "[MindSPONGE] Step: 1710, E_pot: -390.3354, E_kin: 113.09205, E_tot: -277.24335, Temperature: 259.08282\n",
      "[MindSPONGE] Step: 1720, E_pot: -370.21362, E_kin: 91.205, E_tot: -279.0086, Temperature: 208.94173\n",
      "[MindSPONGE] Step: 1730, E_pot: -377.68408, E_kin: 102.35534, E_tot: -275.32874, Temperature: 234.48605\n",
      "[MindSPONGE] Step: 1740, E_pot: -377.8849, E_kin: 123.39969, E_tot: -254.4852, Temperature: 282.6966\n",
      "[MindSPONGE] Step: 1750, E_pot: -370.04028, E_kin: 105.42985, E_tot: -264.61044, Temperature: 241.52945\n",
      "[MindSPONGE] Step: 1760, E_pot: -370.72595, E_kin: 97.11573, E_tot: -273.61023, Temperature: 222.48264\n",
      "[MindSPONGE] Step: 1770, E_pot: -371.8454, E_kin: 124.41217, E_tot: -247.43323, Temperature: 285.0161\n",
      "[MindSPONGE] Step: 1780, E_pot: -365.2735, E_kin: 112.30018, E_tot: -252.97333, Temperature: 257.2687\n",
      "[MindSPONGE] Step: 1790, E_pot: -380.31665, E_kin: 117.67807, E_tot: -262.63858, Temperature: 269.58893\n",
      "[MindSPONGE] Step: 1800, E_pot: -392.35855, E_kin: 139.99095, E_tot: -252.3676, Temperature: 320.70557\n",
      "[MindSPONGE] Step: 1810, E_pot: -401.201, E_kin: 132.19336, E_tot: -269.00763, Temperature: 302.84204\n",
      "[MindSPONGE] Step: 1820, E_pot: -407.71082, E_kin: 134.99782, E_tot: -272.713, Temperature: 309.26678\n",
      "[MindSPONGE] Step: 1830, E_pot: -402.38184, E_kin: 125.35033, E_tot: -277.0315, Temperature: 287.1653\n",
      "[MindSPONGE] Step: 1840, E_pot: -401.52646, E_kin: 124.59781, E_tot: -276.92865, Temperature: 285.44138\n",
      "[MindSPONGE] Step: 1850, E_pot: -386.6041, E_kin: 110.27505, E_tot: -276.32904, Temperature: 252.62932\n",
      "[MindSPONGE] Step: 1860, E_pot: -389.45377, E_kin: 116.72705, E_tot: -272.7267, Temperature: 267.41025\n",
      "[MindSPONGE] Step: 1870, E_pot: -394.58627, E_kin: 112.64981, E_tot: -281.93646, Temperature: 258.0697\n",
      "[MindSPONGE] Step: 1880, E_pot: -390.05948, E_kin: 113.772995, E_tot: -276.2865, Temperature: 260.6428\n",
      "[MindSPONGE] Step: 1890, E_pot: -392.33014, E_kin: 124.54485, E_tot: -267.78528, Temperature: 285.32007\n",
      "[MindSPONGE] Step: 1900, E_pot: -402.78802, E_kin: 122.87929, E_tot: -279.90875, Temperature: 281.5044\n",
      "[MindSPONGE] Step: 1910, E_pot: -396.5669, E_kin: 115.78923, E_tot: -280.77765, Temperature: 265.26178\n",
      "[MindSPONGE] Step: 1920, E_pot: -375.68365, E_kin: 105.96408, E_tot: -269.71957, Temperature: 242.75334\n",
      "[MindSPONGE] Step: 1930, E_pot: -370.06842, E_kin: 103.60245, E_tot: -266.46597, Temperature: 237.34306\n",
      "[MindSPONGE] Step: 1940, E_pot: -385.36517, E_kin: 115.16614, E_tot: -270.19904, Temperature: 263.83435\n",
      "[MindSPONGE] Step: 1950, E_pot: -388.64282, E_kin: 117.21466, E_tot: -271.42816, Temperature: 268.5273\n",
      "[MindSPONGE] Step: 1960, E_pot: -368.59854, E_kin: 104.283516, E_tot: -264.31503, Temperature: 238.90332\n",
      "[MindSPONGE] Step: 1970, E_pot: -380.51584, E_kin: 117.83613, E_tot: -262.67972, Temperature: 269.95105\n",
      "[MindSPONGE] Step: 1980, E_pot: -400.0834, E_kin: 145.69666, E_tot: -254.38675, Temperature: 333.77676\n",
      "[MindSPONGE] Step: 1990, E_pot: -394.53046, E_kin: 128.00021, E_tot: -266.53024, Temperature: 293.23596\n",
      "[MindSPONGE] Finished simulation at 2023-06-30 16:27:45\n",
      "[MindSPONGE] Simulation time: 22.19 seconds.\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<mindsponge.core.sponge.Sponge at 0x7f7a597d37f0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "md.run(2000, callbacks=[run_info, cb_h5md])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mindspore-1.9",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  },
  "vscode": {
   "interpreter": {
    "hash": "768f82fbbece3f0acd424cda825de8aa44edbfaa38d8a3df4ff1437f7ae7861f"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
